package cn.xx.a;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Test4 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("请输入被除数:");
        try { //有可能报错的代码
            int num1 = in.nextInt();
            System.out.print("请输入除数:");
            int num2 = in.nextInt();
            System.out.println(num1+"/"+ num2 +"="+ num1/num2);
        }catch (ArithmeticException e){
            System.err.println("输入的除数不是整数，重新输入");
            e.printStackTrace();  //抛出异常
        }catch (InputMismatchException e){
            System.err.println("除数必须是整数");
            e.printStackTrace();  //抛出异常
        }catch (Exception e){
            System.out.println("其他未知异常");
        }
        finally {
            System.out.println("感谢使用本程序！");
        }
    }
}
